//
//  XMSegmentContentViewController.m
//  XMKit
//
//  Created by Ce Liu on 2018/5/29.
//  Copyright © 2018年 ChenXiaoMing. All rights reserved.
//

#import "XMSegmentContentViewController.h"

// Controller
#import "XMSegmentViewController.h"
#import "XMContentViewController.h"

@interface XMSegmentContentViewController ()

@property (nonatomic, strong) NSMutableArray *dataSource;

@end

@implementation XMSegmentContentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSMutableArray *titles = [NSMutableArray arrayWithCapacity:0];
    for (int i = 0; i < 10; i++) {

        XMContentViewController *con = [[XMContentViewController alloc]init];

        [self.dataSource addObject:con];

        NSString *str = [NSString stringWithFormat:@"第 %d 页", i+1];
        con.titleStr = str;
        [titles addObject:str];
    }

    XMSegmentViewController *segVC = [[XMSegmentViewController alloc]init];
    segVC.viewControllers = self.dataSource;
    segVC.segmentTitles = titles;
    segVC.view.frame = CGRectMake(0, 44, kSCREENWIDTH, self.view.height - 44);
    segVC.selectedIndex = 0;
    [self addChildViewController:segVC];
    [self.view addSubview:segVC.view];
    
}

- (NSMutableArray *)dataSource {
    if (!_dataSource) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
